<!--Header 组件-->
<template>
  <div class="header">
    <div class="header_row">
      <div class="row_log">LOGO</div>
      <div class="row_router">
        <div
          v-for="(item, index) in nav"
          :key="index"
          :class="
            currentIndex == item.router
              ? 'row_router_nav_active row_router_nav_active'
              : 'row_router_nav'
          "
          @click="toRouter(item, index)"
        >
          {{ item.name }}
        </div>
      </div>
      <div class="row-right">
        <div class="right_sign_in">登录</div>
        <div class="right_sign_up">注册</div>
        <div class="right_write-btn">写文章</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "index",
  data() {
    return {
      nav: [
        {
          name: "首页",
          router: "/home/page",
        },
        {
          name: "会员",
          router: "/home/member",
        },
        {
          name: "IT技术",
          router: "/home/journal",
        },
      ],
      currentIndex: "/home/page",
    };
  },
  mounted() {
    this.currentIndex = this.$router.currentRoute.path;
  },
  methods: {
    toRouter(item, index) {
      this.currentIndex = item.router;
      this.$router.push(item.router);
    },
  },
};
</script>

<style scoped lang="less">
.header {
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  overflow: hidden;
  background-color: #fff;
  box-shadow: 0 2px 10px rgb(0 0 0 / 5%);
  z-index: 100;
}
.header_row {
  height: 56px;
  min-width: 1200px;
  max-width: 1440px;
  margin: 0 auto;
  transition: transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  .row_log {
    width: 100px;
    height: 56px;
    line-height: 56rpx;
    text-align: center;
    flex-shrink: 0;
  }
  .row_router {
    display: flex;
    align-items: center;
    flex: 1;
    .row_router_nav {
      height: 56px;
      line-height: 26px;
      padding: 15px;
      color: #333;
      font-size: 17px;
      cursor: pointer;
    }
    .row_router_nav_active {
      color: #ea6f5a;
    }
  }
  .row-right {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 300px;
    .right_sign_in {
      color: #969696;
      display: inline-block;
      margin-bottom: 0;
      font-weight: 400;
      text-align: center;
      vertical-align: middle;
      -ms-touch-action: manipulation;
      touch-action: manipulation;
      cursor: pointer;
      background-image: none;
      border: 1px solid transparent;
      white-space: nowrap;
      padding: 6px 12px;
      font-size: 14px;
      line-height: 1.42857;
      border-radius: 4px;
      -webkit-user-select: none;
      -moz-user-select: none;
      -ms-user-select: none;
      user-select: none;
    }
    .right_sign_up {
      width: 80px;
      height: 38px;
      line-height: 24px;
      border: 1px solid rgba(236, 97, 73, 0.7);
      border-radius: 20px;
      font-size: 15px;
      color: #ea6f5a;
      background-color: transparent;
      text-align: center;
      white-space: nowrap;
      padding: 6px 12px;
      cursor: pointer;
    }
    .right_write-btn {
      width: 100px;
      height: 40px;
      line-height: 40px;
      border-radius: 20px;
      font-size: 15px;
      color: #fff;
      background-color: #ea6f5a;
      text-align: center;
      cursor: pointer;
    }
  }
}
</style>